#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

class Solution1
{
public:
    int removeDuplicates(vector<int>& nums)
    {
        vector<int> v;
        v.push_back(nums[0]);
        vector<int>::iterator it1 = nums.begin();
        vector<int>::iterator it2 = ++(nums.begin());
        while (it2 != nums.end())
        {
            if (*it1 != *it2)
            {
                v.push_back(*it2);
            }
            ++it1, ++it2;
        }
        nums.swap(v);
        return nums.size();
    }
};

class Solution2
{
public:
    int removeDuplicates(vector<int>& nums)
    {
        vector<int> v;
        int x = 0;
        v.push_back(nums[0]);
        for (int i = 1; i < nums.size(); ++i)
        {
            x = nums[i];
            if (find(v.begin(), v.end(), x) == v.end())
            {
                v.push_back(x);
            }
        }
        nums.swap(v);
        return nums.size();
    }
};

int main()
{
    Solution1 s1;
    vector<int> v1;
    for (int i = 0; i < 20; ++i)
    {
        v1.push_back(13);
    }
    s1.removeDuplicates(v1);
    for (int i = 0; i < v1.size(); ++i)
    {
        cout << v1[i] << " ";
    }
    cout << endl;

    Solution2 s2;
    vector<int> v2;
    for (int i = 0; i < 20; ++i)
    {
        v2.push_back(11);
    }
    s2.removeDuplicates(v2);
    for (int i = 0; i < v2.size(); ++i)
    {
        cout << v2[i] << " ";
    }


    return 0;
}